window.workspace = function(){
	var response  = <?#$respons?>;
	var store, grid, sm;
	var sid = {'userid':Ext.id(), 'status':Ext.id(), 'sdate':Ext.id(),
		'edate':Ext.id(), 'state':Ext.id()};
	sm    = new Ext.grid.CheckboxSelectionModel();
	store = new Ext.data.JsonStore({
	    autoDestroy	: true,
	    url			: '/admin/live/finance/salary/dolist.html',
	    remoteSort	: true,
	    sortInfo	: {
            field		: 'id',
            direction	: 'DESC'
		},
		baseParams	: {
			start	: 0,
			limit	: main.pageSize
		},
		autoLoad		: true,
	    root			: 'dataset',
	 	totalProperty	: 'total',
	    fields			: ['id', 'userid', 'nickname', 'avtar', 'starlv', 'qualifiedhours', 
	       'unqualifiedhours', 'bonus','salary', 'star', 'status', 'link', 'addtime', 'starttime', 
	       'endtime', 'audittime', 'operator', 'state', 'ip', 'remark', 'details', 'stime']
	});
 	grid = {
		xtype		: 'grid',
		title		: response.title,
	    store		: store,
		region		: 'center', 
	    columns		: [
	        sm,
			{header: '编号[ID]', width:60, sortable:true, dataIndex:'id'},
			{header: '审批流程', width:60, dataIndex:'link', renderer:function(v){
				return '<a href="'+v+'" target="__blank">点击查看[Details]</a>';
			}},
			{header: '主播信息[Anchor]', width:120, dataIndex:'nickname', renderer:function(v, meta, obj){
				return '<a href="'+obj.get('details')+'" target="__blank">'+v+'</a>';
			}},
			{header: '主播等级[StarLv]', width:60, sortable:true, dataIndex:'starlv', renderer:function(v, meta, obj){
				var data = Ext.decode(obj.get('star'));
				return data.name+'['+data.star+']';
			}},
			{header: '有效时长[Qualifiedhours]', sortable:true, width:70, dataIndex:'qualifiedhours'},
			{header: '无效时长[Unqualifiedhours]', width:70, dataIndex:'unqualifiedhours'},
			{header: '奖金[Bonus]', width:60, sortable:true, dataIndex:'bonus'},
			{header: '工资[Salary]', width:60, sortable:true, dataIndex:'salary'},
			{header: '生成时间[AddTime]', width:80, sortable:true, dataIndex:'addtime'},
			{header: '周期开始[Starttime]', width:80, sortable:true, dataIndex:'starttime'},
			{header: '周期结束[Endtime]', width:80, sortable:true, dataIndex:'endtime'},
			{header: '运营审核状态', width:60, sortable:true, dataIndex:'state', renderer:function(v) {
				return response.status[v];
			}},
			{header: '主管审核状态', width:60, sortable:true, dataIndex:'status', renderer:function(v) {
				return response.status[v];
			}},
			{header: '审核时间', width:80, sortable:true, dataIndex:'audittime'},
			{header: '执行者', width:60, dataIndex:'operator'},
			{header: '执行者IP', width:60, dataIndex:'ip'}
		],
	    viewConfig	: {
	        forceFit	 : true,
	        scrollOffset : 0
	    },
		listeners	: {
			'render':function(obj){
				main.gridRender(obj, ['remark']);
	    	},'rowdblclick':function(grid, index, e) {
		    	var taskurl = grid.store.getAt(index).get('link');
		    	window.open(taskurl);
		    }
		},	
	    sm			: sm,
	    stripeRows	: true,
	    tbar		: [{
			text	: '刷新[Reload]',
			iconCls	: 'icon-refresh',
			handler : function(){
				store.reload(); 
			}
	    },'-','主播[Anchor]:',{
			xtype		: 'combo',
			store		: new Ext.data.JsonStore({
				url		: '/admin/live/share/douser.html',
				autoDestroy: true,
				fields	: ['id', 'name'],
				root	: 'dataset'
			}),
			id				: sid.userid,
			displayField	: 'name',
			valueField		: 'id',
			emptyText		: 'selected...',
			minChars		: 1,
			 pageSize		: 10,
            listWidth		: 258,
            width			: 160,
			typeAhead		: true,
			typeAheadDelay  : 0,
			triggerAction	: 'all',
			enableKeyEvents : true,
			mode			: 'remote'
		},'运营审批:',{
			xtype		: 'combo',
			store		: new Ext.data.ArrayStore({
		        fields: ['id','name'],
		        data: main.cv2Array(response.status)
		    }),
			displayField	: 'name',
			valueField		: 'id',
			mode			: 'local',
			triggerAction	: 'all',
			emptyText		: 'selected...',
			width			: 80,
			id  			: sid.state
		},'运营主管审批:',{
			xtype		: 'combo',
			store		: new Ext.data.ArrayStore({
		        fields: ['id','name'],
		        data: main.cv2Array(response.status)
		    }),
			displayField	: 'name',
			valueField		: 'id',
			mode			: 'local',
			triggerAction	: 'all',
			emptyText		: 'selected...',
			width			: 80,
			id  			: sid.status
		},'生成时间:',{
			xtype       : 'datefield',
			id  		: sid.sdate,
			format      : 'Y-m-d',
			width	    : 100
		},'<->',{
			xtype       : 'datefield',
			id  		: sid.edate,
			format      : 'Y-m-d',
			width	    : 100
		},'-',{
			text			: '检索[Search]',
			iconCls			: 'icon-search',
			handler: function() {
				store.baseParams.userid= Ext.getCmp(sid.userid).getValue();
				store.baseParams.state = Ext.getCmp(sid.state).getValue();
				store.baseParams.status= Ext.getCmp(sid.status).getValue();
				store.baseParams.sdate = Ext.getCmp(sid.sdate).getValue();
				store.baseParams.edate = Ext.getCmp(sid.edate).getValue();
				store.reload(); 
			}
		}],
		bbar		: new Ext.PagingToolbar({
			pageSize	: main.pageSize,
			store		: store,
			displayInfo	: true
		})
	};
	return grid;
}();